package com.wenjunwu.blog.common;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Aspect
public class LogAspect {

	@Around("execution(* com.wenjunwu.blog.service.*.*(..))")
	public Object logAround(ProceedingJoinPoint jp) {
		Object result = null;
		Logger log = null;
		try {
			log = LoggerFactory.getLogger(jp.getTarget().getClass());
			Object[] args = jp.getArgs();
			log.info("请求参数：{} ", args);
			result = jp.proceed(args);
			log.info("响应结果：{} ", result);
		} catch (Throwable e) {
			log.error("日志拦截异常");
			e.printStackTrace();
		}
		return result;
	}
}
